/**
* 左边菜单
*/
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
  export default {
    name: 'leftnav',
    data() {
      return {
        collapsed: false,
        allmenu: []
      }
    },
    // 创建完毕状态(里面是操作)
    created() {
      // 获取图形验证码
      let res = {
        success: true,
        data: [
          {
            menuid: 1,
            icon: 'li-icon-xiangmuguanli',
            menuname: '商品',
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 2,
                icon: 'icon-cat-skuQuery',
                menuname: '商品类别',
                hasThird: 'N',
                url: 'goods/Goods',
                menus: null
              },
              {
                menuid: 3,
                icon: 'icon-cat-skuQuery',
                menuname: '商品品牌',
                hasThird: 'N',
                url: 'goods/GoodsPP',
                menus: null
              },
              {
                menuid: 4,
                icon: 'icon-cat-skuQuery',
                menuname: '商品单位',
                hasThird: 'N',
                url: 'goods/GoodsDW',
                menus: null
              },
              {
                menuid: 5,
                icon: 'icon-cat-skuQuery',
                menuname: '商品编码设置',
                hasThird: 'N',
                url: 'goods/Goods',
                menus: null
              },
              {
                menuid: 6,
                icon: 'icon-cat-skuQuery',
                menuname: '商品档案',
                hasThird: 'N',
                url: 'goods/GoodsDA',
                menus: null
              },
              {
                menuid: 7,
                icon: 'icon-cat-skuQuery',
                menuname: '图片档案',
                hasThird: 'N',
                url: 'goods/Goods',
                menus: null
              },
            ]
          },
          {
            menuid: 30,
            icon: 'li-icon-dingdanguanli',
            menuname: '采购',
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 31,
                icon: 'icon-order-manage',
                menuname: '供应商管理',
                hasThird: 'N',
                url: 'purchase/purchase',
                menus: null
              },
              {
                menuid: 32,
                icon: 'icon-order-manage',
                menuname: '采购单',
                hasThird: 'N',
                url: 'purchase/purchase_order',
                menus: null
              },
              {
                menuid: 33,
                icon: 'icon-order-manage',
                menuname: '采购退货单',
                hasThird: 'N',
                url: 'purchase/purchase_return',
                menus: null
              }
            ]
          },
          {
            menuid: 50,
            icon: 'li-icon-xitongguanli',
            menuname: '库存',
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 51,
                icon: 'icon-cus-manage',
                menuname: '商品入库',
                hasThird: 'N',
                url: 'stock/enterstock/EnterStock',
                menus: null
              },
              {
                menuid: 52,
                icon: 'icon-cms-manage',
                menuname: '库存调拨',
                hasThird: 'N',
                url: 'stock/allocation/Allocation',
                menus: null
              },
              {
                menuid: 53,
                icon: 'icon-news-manage',
                menuname: '商品出库',
                hasThird: 'N',
                url: 'stock/outstock/OutStock',
                menus: null
              },
              {
                menuid: 54,
                icon: 'icon-cs-manage',
                menuname: '库存盘点',
                hasThird: 'N',
                url: 'stock/checkstock/CheckStock',
                menus: null
              },
              {
                menuid: 55,
                icon: 'icon-promotion-manage',
                menuname: '商品库存',
                hasThird: 'N',
                url: 'stock/stock/Stock',
                menus: null
              },
              {
                menuid: 56,
                icon: 'icon-cms-manage',
                menuname: '商品库存明细',
                hasThird: 'N',
                url: 'stock/detailstock/DetailStock',
                menus: null
              }
            ]
          },
          {
            menuid: 70,
            icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
            menuname: '促销',
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 71,
                icon: 'icon-provider-manage',
                menuname: '订单促销',
                hasThird: 'N',
                url: 'promotion/OrderPromotion',
                menus: null
              },
              {
                menuid: 72,
                icon: 'icon-provider-manage',
                menuname: '商品促销',
                hasThird: 'N',
                url: 'promotion/GoodsPromotion',
                menus: null
              }
            ]
          },
          {
            menuid: 90,
            icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
            menuname: '零售',
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 91,
                icon: 'icon-provider-manage',
                menuname: '商品零售',
                hasThird: 'N',
                url: 'retail/salespage',
                menus: null
              },
              {
                menuid: 92,
                icon: 'icon-provider-manage',
                menuname: '终端销售单',
                hasThird: 'N',
                url: 'retail/salesListpage',
                menus: null
              },
              {
                menuid: 93,
                icon: 'icon-provider-manage',
                menuname: '终端退货单',
                hasThird: 'N',
                url: 'retail/returnpage',
                menus: null
              },
              {
                menuid: 94,
                icon: 'icon-provider-manage',
                menuname: '商城销售单',
                hasThird: 'N',
                url: 'retail/mallsales',
                menus: null
              },
              {
                menuid: 95,
                icon: 'icon-provider-manage',
                menuname: '终端销售交易明细',
                hasThird: 'N',
                url: 'retail/transaction',
                menus: null
              },
              {
                menuid: 96,
                icon: 'icon-provider-manage',
                menuname: '终端财务收银明细',
                hasThird: 'N',
                url: 'retail/financialpage',
                menus: null
              },
              {
                menuid: 97,
                icon: 'icon-provider-manage',
                menuname: '终端销售交易汇总',
                hasThird: 'N',
                url: 'retail/transactionsummary',
                menus: null
              },
              {
                menuid: 98,
                icon: 'icon-provider-manage',
                menuname: '终端财务收银汇总',
                hasThird: 'N',
                url: 'retail/financialcashiersummary',
                menus: null
              },
              {
                menuid: 99,
                icon: 'icon-provider-manage',
                menuname: '终端销售退款汇总',
                hasThird: 'N',
                url: 'retail/financialrefundsummary',
                menus: null
              }
            ]
          },
          {
            menuid: 110,
            icon: 'li-icon-dingdanguanli',
            menuname: '会员',
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 111,
                icon: 'icon-order-manage',
                menuname: '会员类别',
                hasThird: 'N',
                url: 'member/MemberType',
                menus: null
              },
              {
                menuid: 112,
                icon: 'icon-order-manage',
                menuname: '会员列表',
                hasThird: 'N',
                url: 'member/MemberList',
                menus: null
              }
            ]
          },
        ],
        msg: 'success'
      }
      this.allmenu = res.data


      // 监听
      this.$root.Bus.$on('toggle', value => {
        this.collapsed = !value
      })
    }
  }
</script>
<style>
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 240px;
    min-height: 400px;
  }
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    border: none;
    text-align: left;
  }
  .el-menu-item-group__title {
    padding: 0px;
  }
  .el-menu-bg {
    background-color: #1f2d3d !important;
  }
  .el-menu {
    border: none;
  }
  .logobox {
    height: 40px;
    line-height: 40px;
    color: #9d9d9d;
    font-size: 20px;
    text-align: center;
    padding: 20px 0px;
  }
  .logoimg {
    height: 40px;
  }
</style>
